package org.geek.week1;

import lombok.SneakyThrows;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

/**
 * @author wangnan
 * @create 2021/9/18
 */
public class Util {

    public static String textDecode(String s){
        try {
            final String decode = URLDecoder.decode(s, "utf-8");
            return decode;
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return null;
    }
    private static  void run(){
        long l=System.currentTimeMillis();
        try {
            Integer a=10000;
            List<Integer> list = new LinkedList<>();
            while (System.currentTimeMillis()-l<TimeUnit.MILLISECONDS.convert(1,TimeUnit.MINUTES)) {
                for(int i=0;i<900000;i++)
                {
                    a=new Integer(i);
                    list.add(a);
                }

                TimeUnit.SECONDS.sleep(1);
            }

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    private static  void run2(){
        long l=System.currentTimeMillis();
            int max  =100000*10;
           Integer a=10000;
            List<Integer> list = new ArrayList<>(max);
                for(int i=0;i<max;i++)
                {
                    // Integer    a=new Integer(i);
                        a=new Integer(i);
                    list.add(a);
                }
    }
    public static void main(String[] args) {
        HashMap map = new HashMap<>();
        map.put(null, null);
      Thread thread=new Thread(()->{
          while (true) {
              run2();
              try {
                  TimeUnit.MILLISECONDS.sleep(0);
              } catch (InterruptedException e) {
                  break;
              }
          }
      });
        thread.setName("test-thread");
       thread.start();
        Thread thread2=new Thread(()->{
            while (true) {
                run2();
                try {
                    TimeUnit.SECONDS.sleep(0);
                } catch (InterruptedException e) {
                    break;
                }
            }

        });
        thread2.setName("test2-thread2");
        thread2.start();
        System.out.println("run end");
        try {

             TimeUnit.DAYS.sleep(1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
